const spawn = require("child_process").spawn
const py = spawn("python", ['main.py'])


cluster = {
    search_tag: "意大利夺冠",
    detail: ["2020", "温布利球场", "英格兰"]
}

chunks = []

// 获取python返回的值
py.stdout.on("data", data => chunks.push(data))

// 当python子进程结束时，输出返回的东西
py.stdout.on('end', function () {
    const data = JSON.parse(Buffer.concat(chunks).toString());
    console.log(data)
    console.log("python process end...");
});

// 将数据传给python
py.stdin.write(JSON.stringify(cluster))
py.stdin.end()